package org.zerg.controller.api;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.zerg.entity.Theme;
import org.zerg.service.ThemeService;

@Controller
@RequestMapping("/api")
public class ThemeController {

	@Autowired
	private ThemeService themeService;
	
	@RequestMapping(value="/theme", method = RequestMethod.GET,
            produces = {"application/json;charset=UTF-8"})
	@ResponseBody
	public List<Theme> getThemeList(){
		List<Theme> list = themeService.getThemeList();
		return list;
	}
	
	@RequestMapping(value="/{id}/theme", method = RequestMethod.GET,
            produces = {"application/json;charset=UTF-8"})
	@ResponseBody
	public Theme getThemeById(@PathVariable(value="id") int id){
		Theme theme = themeService.getThemeById(id);
		return theme;
	}
}
